<template>
<div style="margin-left: 500px">
  <el-form
      :label-position="labelPosition"
      label-width="100px"
      :model="formLabelAlign"
      style="max-width: 460px"
  >
    <el-form-item label="手机号">
      <el-input v-model="formLabelAlign.phoneNumber" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="formLabelAlign.password" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="login1">登录</el-button>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="d">注册</el-button>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="logout">退出登陆</el-button>
    </el-form-item>
  </el-form>

</div>
</template>

<script  setup>
import {baseURL} from "@/request/index.js";
import { useRouter } from "vue-router";
import { reactive, ref } from 'vue'
import axios from "axios";
import {useUserStore} from "@/Store/Pinia/pinia";
const useStore=useUserStore();
const router=useRouter();
const labelPosition = ref('right')
const formLabelAlign = reactive({
  phoneNumber: 19169702017,
  password: "LYJLYJ20010426",
})
const id=ref(0);

function  login(){
  useStore.login();
  alert("登录成功")
  router.push({path:"/"})
}

function login1(){
  axios.post(baseURL+"/login/cellphone?phone=19169702017&password=LYJLYJ20010426").then(res=>{
    console.log(res);
  })
  login();
  loginrefresh();
  loginstatus();
}
function loginstatus(){
  console.log(baseURL)
  axios.post(baseURL+"/login/status").then(res=>{
    console.log(res);
  })
}
function loginrefresh() {
  axios.post("http://localhost:3000/login/refresh").then(res=>{
    console.log(res);
  })
}
</script>

<style scoped>

</style>